/**
 * 
 */
package com.mwyq.service;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.mwyq.dao.NewsMapper;
import com.mwyq.model.News;
import com.mwyq.model.NewsExample;


@Service
public class NewsService {
	
	@Resource
	private NewsMapper newsMapper;
	
	public List<News> getAllNews(){
		NewsExample example = new NewsExample();
		List<News> newsAll = newsMapper.selectByExample(example);
		
		return newsAll;
	}
	
	/**
	 * 以时间顺序获取新闻列表
	 * **/
	public List<News> getLatestNews(){
		NewsExample example = new NewsExample();
		example.setOrderByClause("news_time");
		
		List<News> latestNews = newsMapper.getLastestNews();
		
		//Collections.sort(latestNews,Collections.reverseOrder());
		
		
		return latestNews;
	}
	/**
	 * 获取新闻的内容
	 * **/
	public List<News> getNewsContent(int newsid){
		NewsExample example = new NewsExample();
		NewsExample.Criteria criteria = example.createCriteria();
		criteria.andNews_idEqualTo(newsid);
//		criteria.andNews_timeEqualTo(time1);
		
//		int a = newsMapper.countByExample(example);
		List<News> newsContent = newsMapper.selectByExample(example);
		
		return newsContent;
	}
}
